let pool = [];
export class MySubmitTarget extends Laya.SubmitTarget {
    renderSubmit(): number {
        var gl = Laya.WebGLContext['mainContext'];
        this['_mesh'].useMesh(gl);
        this.shaderValue.upload();
        this.blend();
        Laya.Stat.renderBatches++;
        Laya.Stat.trianglesFaces += this['_numEle'] / 3;
        gl.drawElements(gl.TRIANGLES, this['_numEle'], gl.UNSIGNED_SHORT, this['_startIdx']);
        return 1;
    }

    static create(context, mesh, sv) {
        var o = pool.length > 0 ? pool.pop() : new MySubmitTarget();
        o._mesh = mesh;
        o._startIdx = mesh.indexNum * Laya.CONST3D2D.BYTES_PIDX;
        o._ref = 1;
        o._key.clear();
        o._numEle = 0;
        o.blendType = context._nBlendType;
        o._key.blendShader = o.blendType;
        o.shaderValue = sv;
        o.shaderValue.setValue(context._shader2D);
        if (context._colorFiler) {
            var ft = context._colorFiler;
            sv.defines.add(ft.type);
            sv.colorMat = ft._mat;
            sv.colorAlpha = ft._alpha;
        }
        return o;
    }

    releaseRender() {
        if ((--this['_ref']) < 1) {
            pool.push(this);
        }
    }
}